package org.mspring.mlog.dao.impl;

import java.util.List;

import org.mspring.mlog.dao.JobDao;
import org.mspring.mlog.entity.Job;
import org.mspring.platform.dao.hibernate.GenericDao;
import org.springframework.stereotype.Repository;

/**
 *
 * @author Gao Youbo
 * @since 2014-01-11
 */
@Repository
public class JobDaoImpl extends GenericDao<Job, Long> implements JobDao {

    @Override
    public void setEnabled(long id, boolean enabled) {
        super.executeUpdate("update Job job set job.enabled = ? where job.id = ?", enabled, id);
    }

    @Override
    public void setExpression(long id, String expression) {
        super.executeUpdate("update Job job set job.expression = ? where job.id = ?", expression, id);
    }

    @Override
    public void setExecType(long id, String execType) {
        super.executeUpdate("update Job job set job.execType = ? where job.id = ?", execType, id);
    }

    @Override
    public List<Job> listEnabled() {
        return super.list("select job from Job job where job.enabled = ?", true);
    }

}
